; *** Knight's Tour
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com
(translate
 ("Knight's Tour 4x5" "马跳棋盘 4x5") ("Knight's Tour 6x6" "马跳棋盘 6x6")
 ("Knight's Tour Solitaire" "马跳棋盘 独立钻石") ("Knight's Tour 8x8" "马跳棋盘 8x8")
 ("Bishop's Tour" "象走棋盘") ("Camel's Tour" "骆驼跳棋盘")
)
(version "2.0")

(game
   (title "Knight's Tour 4x5")
   (solution "Solutions\Knight's_Tour\Knight'sTour_4x5.zsg")
   (description "走遍整个棋盘。每个位置只能经过一次。")
   (history "The Knight's Tour puzzle is almost as old as Chess itself, with 
      solutions dating back to at least 850 A.D. (see Murray's `A History of Chess`).
      Interest in Knight's Tours was revived in the 1700's by mathematicians including
      de Moivre and Euler, and the problem has continued to maintain the interest of
      puzzlers and recreational mathematicians, who have discovered many interesting
      properties of tours on boards of various sizes.    There is now an enormous
      literature on the subject.")
   (strategy "Keep in mind that there are only two squares that are a Knight's
      leap away from a corner square.  If you take away one of these squares
      without proceeding to the corner, you won't be able to go to a corner
      later and exit again.   In 1823, H. C. Warnsdorff proposed a useful general
      rule of strategy: always move the knight to a square where it can move to
      the fewest possible squares not already visited.\\
      To see a solution, select `Show Solution` under the Help menu.")
   (option "animate captures" false)
   (opening-sound "Audio\\Horse.wav")
   (players Player)
   (turn-order Player)
   (piece
      (name Knight)
      (description "马\跳日字，即横1步竖2步，或横2步竖1步。")
      (help "马：跳日。")
      (image Player "images\Chess\SHaag\wknight.bmp")
      (moves
	     (nne (verify not-empty?) add)
	     (nnw (verify not-empty?) add)
	     (sse (verify not-empty?) add)
	     (ssw (verify not-empty?) add)
	     (ene (verify not-empty?) add)
	     (ese (verify not-empty?) add)
	     (wnw (verify not-empty?) add)
	     (wsw (verify not-empty?) add)
      )
   )
   (piece
     (name Light)
     (image Player "images\KnightsTour\Light.bmp" "images\KnightsTour\Heads.bmp")
     (help "此格还未走过。")  
   )   
   (piece
     (name Dark)
     (image Player "images\KnightsTour\Dark.bmp" "images\KnightsTour\Heads.bmp")
     (help "此格还未走过。")  
   )   
   (board 
     (image "images\KnightsTour\Egypt_4x5.bmp" "images\Chess\SHaag\Chess4x5.bmp")
     (grid
       (start-rectangle 5 5 53 53)
       (dimensions
         ("a/b/c/d" (49 0)) ; files
         ("5/4/3/2/1" (0 49)) ; ranks
       )
       (directions (nnw -1 -2) (nne  1 -2) (ene  2 -1) (ese  2  1)
	               (sse  1  2) (ssw -1  2) (wsw -2  1) (wnw -2 -1)
       )
     )
   )
   (board-setup
     (Player
       (Knight off 99 a1)
       (Light off 0    b5    d5
                    a4    c4   
                       b3    d3
                    a2    c2   
                       b1    d1)
       (Dark off 0  a5    c5    
                       b4    d4
                    a3    c3   
                       b2    d2
                          c1   ))
   )
   (win-condition (Player) (pieces-remaining 0 Light))
   (loss-condition (Player) stalemated )
)

(variant
   (title "Knight's Tour 6x6")
   (description "走遍整个棋盘。每个格只能走一次。")
   (solution "Solutions\Knight's_Tour\Knight'sTour_6x6.zsg")
   (board
     (image "images\KnightsTour\Apollo11_6x6.bmp" "images\Chess\SHaag\Chess6x6.bmp")
     (grid
       (start-rectangle 5 5 53 53)
       (dimensions
          ("a/b/c/d/e/f" (49 0)) ; files
          ("6/5/4/3/2/1" (0 49)) ; ranks
       )
       (directions (nnw -1 -2) (nne  1 -2) (ene  2 -1) (ese  2  1)
	               (sse  1  2) (ssw -1  2) (wsw -2  1) (wnw -2 -1)
       )
     )
   ) 
   (board-setup
     (Player
       (Knight a1)
       (Light off 0 a6    c6    e6   
                       b5    d5    f5
                    a4    c4    e4   
                       b3    d3    f3
                    a2    c2    e2   
                       b1    d1    f1)
       (Dark off 0     b6    d6    f6
                    a5    c5    e5   
                       b4    d4    f4
                    a3    c3    e3   
                       b2    d2    f2
                          c1    e1   ))
   )
)

(variant
   (title "Knight's Tour Solitaire")
   (description "独立钻石棋盘的遍历问题\\
      走遍整个棋盘。每个格只能走一次。")
   (solution "Solutions\Knight's_Tour\Knight'sTourSolitaire.zsg")
   (board 
     (image "images\KnightsTour\Deer_7x7.bmp" "images\Chess\SHaag\ChessSolitaire.bmp")
     (grid
       (start-rectangle 5 5 53 53)
       (dimensions
         ("a/b/c/d/e/f/g" (49 0)) ; files
         ("7/6/5/4/3/2/1" (0 49)) ; ranks
       )
       (directions (nnw -1 -2) (nne  1 -2) (ene  2 -1) (ese  2  1)
	               (sse  1  2) (ssw -1  2) (wsw -2  1) (wnw -2 -1)
       )
     )
     (kill-positions a1 a2 b1 b2 a6 a7 b6 b7 f1 f2 g1 g2 f6 f7 g6 g7)
   )
   (board-setup
     (Player
       (Knight off 99 d7)
       (Light off 0                     
                          c6    e6      
                       b5    d5    f5   
                    a4    c4    e4    g4 
                       b3    d3    f3  
                          c2    e2    
                             d1 )
       (Dark off 0        c7    e7    
                             d6         
                    a5    c5    e5    g5
                       b4          f4   
                    a3    c3    e3    g3
                             d2          
                          c1    e1    ))
   )
   (win-condition (Player) (pieces-remaining 0 Dark))
   (loss-condition (Player) stalemated )
)

(variant
   (title "Knight's Tour 8x8")
   (description "走遍整个棋盘。每个格只能走一次。")
   (solution "Solutions\Knight's_Tour\Knight'sTour_8x8.zsg")
   (board 
     (image "images\KnightsTour\CavePainting_8x8.bmp" "images\Chess\SHaag\Chess8x8.bmp")
     (grid
       (start-rectangle 5 5 53 53)
       (dimensions
         ("a/b/c/d/e/f/g/h" (49 0)) ; files
         ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
       )
       (directions (nnw -1 -2) (nne  1 -2) (ene  2 -1) (ese  2  1)
	               (sse  1  2) (ssw -1  2) (wsw -2  1) (wnw -2 -1)
       )
     )
   )
   (board-setup
     (Player
       (Knight off 99 a1)
       (Light off 0 a8    c8    e8    g8
                       b7    d7    f7    h7 
                    a6    c6    e6    g6
                       b5    d5    f5    h5
                    a4    c4    e4    g4 
                       b3    d3    f3    h3
                    a2    c2    e2    g2
                       b1    d1    f1    h1)
       (Dark off 0     b8    d8    f8    h8
                    a7    c7    e7    g7
                       b6    d6    f6    h6
                    a5    c5    e5    g5
                       b4    d4    f4    h4
                    a3    c3    e3    g3
                       b2    d2    f2    h2
                          c1    e1    g1))
   )
)

(variant (title "-"))

(define slide (
   $1 add
   mark capture $1 add
   back capture $1 capture $1 add
   back capture $1 capture $1 capture $1 add
   back capture $1 capture $1 capture $1 capture $1 add
   back capture $1 capture $1 capture $1 capture $1 capture $1 add
   back capture $1 capture $1 capture $1 capture $1 capture $1 capture $1 add
))

(variant
   (title "Bishop's Tour")
   (description "走遍整个棋盘的黑格。每个格只能走一次。")
   (history "The puzzle king Henry Ernest Dudeney presented a slightly different
      problem in the early 1900's called `The Fly's Tour.`  In his puzzle, a
      fly at one corner of the chessboard tries to visit every square of the
      color he starts on without visiting squares of the opposite color.  The fly
      does this by passing through intersections, but he may never pass through
      the same intersection twice.  `It can be done in seventeen continuous
      straight courses.`")
   (strategy "Try to slide along lines that enter a lot of unvisited squares and set
      you up for another good move.\\
      To see a 17-move solution, select `Show Solution` under the Help menu.")
   (solution "Solutions\Knight's_Tour\Bishop'sTour.zsg")
   (opening-sound "")
   (board 
     (image "images\Chess\SHaag\Chess8x8.bmp")
     (grid
       (start-rectangle 5 5 53 53)
       (dimensions
         ("a/b/c/d/e/f/g/h" (49 0)) ; files
         ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
       )
       (directions (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1) )
     )
     (kill-positions a2 a4 a6 a8 b1 b3 b5 b7 c2 c4 c6 c8 d1 d3 d5 d7
                     e2 e4 e6 e8 f1 f3 f5 f7 g2 g4 g6 g8 h1 h3 h5 h7)
   )
   (piece
     (name Dark)
     (image Player "images\KnightsTour\Highlight.bmp" "images\KnightsTour\Heads.bmp")
     (help "此格还未走过。")  
   )   
   (piece
      (name Bishop)
	  (help "象：走斜线，格数不限、")
      (description "Bishop\A Bishop moves any number of squares in a straight
	      line diagonally.")
      (image Player "images\Chess\SHaag\wbishop.bmp" "images\Chess\SHaag\wbishop.bmp")
      (moves
         (slide ne) (slide nw) (slide se) (slide sw)
      )
   )
   (piece (name Knight))
   (board-setup
     (Player
       (Bishop off 99 a1)
       (Dark off 0     b8    d8    f8    h8
                    a7    c7    e7    g7
                       b6    d6    f6    h6
                    a5    c5    e5    g5
                       b4    d4    f4    h4
                    a3    c3    e3    g3
                       b2    d2    f2    h2
                          c1    e1    g1   ))
   )
   (win-condition (Player)
      (and (absolute-config Bishop (h8)) (pieces-remaining 0 Dark) )
   )
)

(variant (title "-"))

(variant
   (title "Camel's Tour")
   (description "走遍整个棋盘的黑格。每个格只能走一次。\
骆驼（Camel）走目字，即横3步竖1步，或横1步竖3步。")
   (strategy "Solomon Golomb, who posed the problem originally, solved the
      problem by looking at the chessboard diagonally, so that the dark squares
       formed a 32-square diamond playing field.  Camels can be seen to move
       as normal Knights on this surface and the Camel's tour on a regular chessboard
       is equivalent to a Knight's tour there.\\
       To see the solution, select `Show Solution` under the Help menu.")
   (history "This puzzle was posed by Solomon Golomb, who called the Camel
      a `Cook`.  Martin Gardner discusses the problem in Scientific American 7 (1967).")
   (solution "Solutions\Knight's_Tour\Camel'sTour.zsg")
   (opening-sound "")
   (board 
     (image "images\KnightsTour\Lizard_8x8.bmp" "images\Chess\SHaag\Chess8x8.bmp")
     (grid
       (start-rectangle 5 5 53 53)
       (dimensions
         ("a/b/c/d/e/f/g/h" (49 0)) ; files
         ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
       )
       (directions (nnnw -1 -3) (nnne  1 -3) (eeen  3 -1) (eees  3  1)
                   (ssse  1  3) (sssw -1  3) (wwws -3  1) (wwwn -3 -1)
       )
     )
   )
   (piece (name Knight))
   (piece
      (name Camel)
      (description "骆驼\走目字，即横3步竖1步，或横1步竖3步。")
      (help "骆驼：跳目字")
      (image Player "images\Chess\SHaag\wknight.bmp")
      (moves
	     (nnne (verify not-empty?) add)
	     (nnnw (verify not-empty?) add)
	     (ssse (verify not-empty?) add)
	     (sssw (verify not-empty?) add)
	     (eeen (verify not-empty?) add)
	     (eees (verify not-empty?) add)
	     (wwwn (verify not-empty?) add)
	     (wwws (verify not-empty?) add)
      )
   )
   (board-setup
     (Player
       (Camel a1)
       (Dark off 0     b8    d8    f8    h8
                    a7    c7    e7    g7
                       b6    d6    f6    h6
                    a5    c5    e5    g5
                       b4    d4    f4    h4
                    a3    c3    e3    g3
                       b2    d2    f2    h2
                          c1    e1    g1   ))
   )
   (win-condition (Player) (pieces-remaining 0 Dark))
   (loss-condition (Player) stalemated )
)